# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=ipython2
_pkgname=ipython
pkgver=5.10.0
pkgrel=4
pkgdesc='Provides a rich toolkit to help you make the most out of using Python interactively.'
url='https://pypi.org/project/ipython/#files'
arch=('any')
license=('BSD')
depends=('python2' 'python2-simplegeneric' 'python2-pexpect' 'python2-pathlib'
         'python2-pickleshare' 'python2-setuptools' 'python2-prompt_toolkit1'
         'python2-backports.shutil_get_terminal_size' 'python2-traitlets'
         'sqlite')
makedepends=('python2-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
        'http://www.packal.org/sites/default/files/public/styles/icon_large/public/workflow-files/nkeimipynbworkflow/icon/icon.png')
sha512sums=('6263f7c9caaa1dbaac58d99adcf58ccb0b7b204f5d0ebf667474aaf567af8734a7240e6756793e69a4e3fe674cef5c75da87f4c79cea0095e4cde48f4eeca84a'
            'defa879afcbe55957de381a6c9e7a0276237015a33221958354dc3ae13e0ed66a25e00b28e857c1d3d4cedd9baf15d2bbeefee94cf1f35e170b87a923fea9952')

prepare() {
  cd "$_pkgname-$pkgver"

  find ./ -type f -exec sed -i -e 's/prompt_toolkit/prompt_toolkit1/g' {} \;
}

build() {
  cd "$_pkgname-$pkgver"

  python2 setup.py build
}

package() {
  cd "$_pkgname-$pkgver"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O0

  # .desktop + icon shit
  sed -i 's|python|python2|g' "examples/IPython Kernel/"*.desktop
  sed -i 's|gnome-netstatus-idle|ipython2|g' "examples/IPython Kernel/"*.desktop
  install -Dm 644 "examples/IPython Kernel/ipython.desktop" \
    "$pkgdir/usr/share/applications/ipython2.desktop"
  install -Dm 644 "$srcdir/icon.png" "$pkgdir/usr/share/pixmaps/ipython2.png"

  rm -rf "$pkgdir/usr/share/"

  mv "$pkgdir/usr/bin/$_pkgname" "$pkgdir/usr/bin/${pkgname}"
  mv "$pkgdir/usr/bin/iptest" "$pkgdir/usr/bin/iptest2"
}

